home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / drivers1.zip / AT&T_LP.ASM < prev    next >
Assembly Source File  |  1992-01-23  |  8KB  |  292 lines

  1. version    equ    1
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210, by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;Updated to version 1.08 Feb. 17, 1989 by Russell Nelson.
  9. ;Updated to support 1500 byte MTU April 27, 1989 By Brad Clements.
  10. ;converted to an AT&T driver Feb 16, 1990 by Russell Nelson
  11. ;modified to support T7231-based AT&T NICs June 1, 1991 by Mark Darby.
  12.  
  13. ;  Copyright, 1988-1992, Russell Nelson
  14.  
  15. ;   This program is free software; you can redistribute it and/or modify
  16. ;   it under the terms of the GNU General Public License as published by
  17. ;   the Free Software Foundation, version 1.
  18. ;
  19. ;   This program is distributed in the hope that it will be useful,
  20. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. ;   GNU General Public License for more details.
  23. ;
  24. ;   You should have received a copy of the GNU General Public License
  25. ;   along with this program; if not, write to the Free Software
  26. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  
  28. code    segment    word public
  29.     assume    cs:code, ds:code
  30.  
  31. ;
  32. ;  Equates for controlling the AT&T boards
  33. ;
  34. ;  I/O addresses, writing anything in AL trips these gates
  35. ;
  36. ;  First six addresses are the EPROM board Ether address (read)
  37. ;
  38. IORESET    EQU    0            ; reset the board
  39. IOCA    EQU    1            ; Channel Attention
  40. IOREV    EQU    6            ; Board Revision/Type
  41. IOATTR    EQU    7            ; Attribute Register.
  42.  
  43. ;Attribute register contents:
  44. attr_mem    equ    03h        ;mask for memory size
  45. attr_mem_64    equ    0
  46. attr_mem_16    equ    1
  47. attr_mem_32    equ    2
  48. attr_mem_8    equ    3
  49. ;
  50. attr_bw        equ    04h        ;Bus width (0=8 bit, 1=16 bit)
  51. attr_speed    equ    08h        ;Board speed (0=10 Mhz, 1=1 Mhz)
  52. attr_c        equ    10h        ;Manchester code (0=Manchester, 1=NRZ)
  53. attr_hw        equ    20h        ;Host bus width (0=16, 1=8 bit)
  54. attr_es        equ    40h        ;Ethernet/Starlan (0 = E, 1 = S)
  55. attr_b        equ    80h        ;Boot Rom (0=No ROM, 1=ROM)
  56.  
  57. IOMISC    equ    9
  58. ;
  59. attr_li        equ    02h        ;LI enable (0=no, 1=yes)
  60. attr_md        equ    04h        ;net media (0=AUI, 1=TP)
  61. attr_inen    equ    08h        ;interrupt enable (0=off, 1=on)
  62. attr_bus8    equ    10h        ;force 8-bit mode (0=no, 1=yes)
  63.  
  64. IOINTR    equ    12            ;interrupt select register
  65. ;
  66. ;  Data segment
  67. ;
  68.  
  69.     public    int_no
  70. int_no        db        2,0,0,0        ; interrupt number. 
  71. io_addr        dw        0360h,0        ; I/O address for card (jumpers)
  72. base_addr    dw      0d000h,0    ; base segment for board (jumper set)
  73. media_sel    db        0,0,0,0        ; media select (AUI or TP)
  74. li_enabl    db        0,0,0,0        ; link integrity enable
  75.  
  76.  
  77.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  78. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  79. driver_type    db    48        ;from the packet spec
  80. driver_name    db    20 dup(?)    ;name of the driver.
  81. driver_function    db    2
  82. parameter_list    label    byte
  83.     db    1    ;major rev of packet driver
  84.     db    9    ;minor rev of packet driver
  85.     db    14    ;length of parameter list
  86.     db    EADDR_LEN    ;length of MAC-layer address
  87.     dw    GIANT    ;MTU, including MAC headers
  88.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  89.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  90.     dw    0    ;(# of successive xmits) - 1
  91. int_num    dw    0    ;Interrupt # to hook for post-EOI
  92.             ;processing, 0 == none,
  93.  
  94. enable_network:
  95. ;  connect to network
  96.     ret
  97.  
  98.  
  99. reset_586:
  100. ;  Reset the chip
  101.     loadport
  102.     setport    IORESET
  103.     out    dx,al
  104.     ret
  105.  
  106.  
  107.     public    get_address
  108. get_address:
  109. ;get the address of the interface.
  110. ;enter with es:di -> place to get the address, cx = size of address buffer.
  111. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  112.     assume    ds:code
  113.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  114.     jb    get_address_2
  115.     mov    cx,EADDR_LEN
  116.     mov    dx,io_addr        ; Get our IO base address.
  117.     cld
  118. get_address_1:
  119.     in    al,dx            ; get a byte of the eprom address
  120.     stosb                ; put it away
  121.     inc    dx            ; next register
  122.     loop    get_address_1        ; go back for rest
  123.     mov    cx,EADDR_LEN
  124.     clc
  125.     ret
  126. get_address_2:
  127.     stc
  128.     ret
  129.  
  130.  
  131. doca:
  132. ;we may be called from places in which ds is unknown.
  133.     assume    ds:nothing
  134.     loadport
  135.     setport    IOCA
  136.     out    dx,al            ; send it
  137.     ret
  138.     assume    ds:code
  139. ;yet, we really should assume ds==code for the rest of this stuff.
  140.  
  141. ;
  142. ; Here we include the code that is common between T7231 implementations.
  143. ; Everything above this is resident.
  144.     include    t7231.asm
  145. ; Everything below this is discarded upon installation.
  146.  
  147.     public    usage_msg
  148. usage_msg    db    "usage: at&t_lp [-n] [-d] [-w] <packet_int_no> <int_no> <io_addr> <base_addr> <media_sel> <li_enabl>",CR,LF,'$'
  149.  
  150.     public    copyright_msg
  151. copyright_msg    db    "Packet driver for the AT&T LanPACER/StarStation boards, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+t7231_version,CR,LF
  152.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  153.  
  154. board_name_list    dw    board_04, board_06, board_16, board_08, board_unk
  155.  
  156. board_04    db    04h, "StarStation",0,79
  157. board_06    db    06h, "LanPACER+ NAU",0,77
  158. board_16    db    16h, "LanPACER NAU",0,76
  159. board_08    db  08h, "EVB",0,78
  160. board_unk    db    -1h, "Unknown AT&T",0,77  ;just a guess.
  161.  
  162.     extrn    chrout: near
  163.  
  164. check_board:
  165.     assume    ds:code
  166.     loadport
  167.     setport    IOREV
  168.     in    al,dx
  169.     mov    bx,offset board_name_list
  170. check_board_name:
  171.     mov    si,[bx]            ;get a pointer to a string.
  172.     add    bx,2
  173.     cmp    byte ptr [si],-1    ;is this the end?
  174.     je    check_board_found
  175.     cmp    al,[si]            ;is this the right one?
  176.     jne    check_board_name
  177. check_board_found:
  178.     inc    si            ;skip the board revision number.
  179.  
  180.     mov    dx,offset this_board_msg
  181.     mov    ah,9
  182.     int    21h
  183.  
  184.     mov    ax,ds            ;copy the driver name to where
  185.     mov    es,ax            ;  we need it.
  186.     mov    di,offset driver_name
  187. check_board_copy:
  188.     lodsb
  189.     stosb
  190.     or    al,al
  191.     je    check_board_done_print
  192.     call    chrout            ;print the character.
  193.     jmp    check_board_copy
  194. check_board_done_print:
  195.     lodsb                ;copy the driver type number over
  196.     mov    driver_type,al
  197.     mov    al,CR
  198.     call    chrout
  199.     mov    al,LF
  200.     call    chrout
  201.  
  202.     loadport
  203.     setport    IOATTR
  204.     in    al,dx            ;get the bus width bit into bit zero.
  205.     shr    al,1
  206.     shr    al,1
  207.     not    al
  208.     and    al,1            ;and negate it.
  209.     mov    SCP,al            ;that makes it into the bus width flag.
  210.  
  211.     in    al,dx            ;get the manchester code
  212.     shr    al,1
  213.     shr    al,1
  214.     not    al            ;the bit is flipped.
  215.     and    al,4            ;isolate just the manchester/~nrz bit.
  216.     mov    byte ptr CBCONF_FLAGS,al
  217.  
  218.     mov    dx,io_addr    ; i/o address
  219.     in    al,dx
  220.     mov    bl,al        ; assemble pattern to check
  221.     inc    dx
  222.     in    al,dx
  223.     mov    bh,al
  224.     cmp    bx,0008h    ; pattern known to be there in ROM
  225.     jz    have_att_io
  226.     pop    dx            ;drop our return address
  227.     mov    dx,offset no_att_io_msg
  228.     jmp    error
  229. have_att_io:
  230.  
  231.     mov    ax,base_addr
  232.     mov    cx,2000h        ;test only what we are going to use.
  233.     call    memory_test
  234.     jz    have_att_mem
  235.     pop    dx            ;drop our return address
  236.     mov    dx,offset no_att_mem_msg
  237.     jmp    error
  238. have_att_mem:
  239.     ret
  240.  
  241.  
  242. this_board_msg    db    "This board is an AT&T ",'$'
  243. no_att_io_msg    db    "No AT&T board found at that I/O address.",CR,LF,'$'
  244. no_att_mem_msg    db    "No AT&T board found at that memory address.",CR,LF,'$'
  245.  
  246.     public    parse_args
  247. parse_args:
  248.     mov    di,offset int_no
  249.     call    get_number
  250.     mov    di,offset io_addr
  251.     call    get_number
  252.     mov    di,offset base_addr
  253.     call    get_number
  254.     mov    di,offset media_sel
  255.     call    get_number
  256.     mov    di,offset li_enabl
  257.     call    get_number
  258.     clc
  259.     ret
  260.  
  261.  
  262. int_no_name    db    "Interrupt number ",'$'
  263. io_addr_name    db    "I/O port ",'$'
  264. base_addr_name    db    "Memory address ",'$'
  265.  
  266.  
  267.     public    print_parameters
  268. print_parameters:
  269.     mov    di,offset int_no
  270.     mov    dx,offset int_no_name
  271.     call    print_number
  272.     mov    di,offset io_addr
  273.     mov    dx,offset io_addr_name
  274.     call    print_number
  275.     mov    ax,memory_begin
  276.     mov    cl,4
  277.     shr    ax,cl
  278.     add    base_addr,ax
  279.     push    ax
  280.     mov    di,offset base_addr
  281.     mov    dx,offset base_addr_name
  282.     call    print_number
  283.     pop    ax
  284.     sub    base_addr,ax
  285.     ret
  286.  
  287.     include    memtest.asm
  288.  
  289. code    ends
  290.  
  291.     end
  292.